﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.IO;
using Microsoft.Win32;

namespace RemoteDesktop
{
    /// <summary>
    /// Interaction logic for ShareButton.xaml
    /// </summary>
    public partial class ShareButton : UserControl
    {
        public ShareButton()
        {
            InitializeComponent();
        }

        private void btnSetWallpaper_Click(object sender, RoutedEventArgs e)
        {
            FileInfo f = null;
            OpenFileDialog dlg;
            dlg = new OpenFileDialog();

            //Open the Pop-Up Window to select the file 
            bool? result = dlg.ShowDialog();
            if (result == true)
            {
                f = new FileInfo(dlg.FileName);
                using (Stream s = dlg.OpenFile())
                {



                    if ((Application.Current.MainWindow as Window1).lstMembers.SelectedIndex >= 0)
                    {
                        List<string> recipients = new List<string>();

                        foreach (string li in (Application.Current.MainWindow as Window1).lstMembers.SelectedItems)
                            recipients.Add(li);
                         try
                        {
                            (Application.Current.MainWindow as Window1).Participant.SetWallPaper((Application.Current.MainWindow as Window1).Member,recipients, s );
                        }
                         catch (Exception ex)
                         {
                             MessageBox.Show("An error has occured.");
                         }
                    }


                       
                          
                        

                }
            }
        }
    }
}
